//
//  LBPathFind.h
//  LittleBall
//
//

#import <Foundation/Foundation.h>

#define mapWidth      10
#define mapHeight     10
#define notFinished   0
#define notStarted    0
#define found         1
#define nonexistent   2
#define stepsize      20


typedef enum
{
    walkable = 0,
    unwalkable = 1
}MapNodeWalkability;

@interface LBPathFind : NSObject
{
    int walkability[mapWidth][mapHeight]; // 地图区块的可通过性（比如10*10的区块）
	int openList[mapWidth*mapHeight];      // 开集二进制数组堆
	int whichList[mapWidth][mapHeight];    // 二维数组用来表征区块处于开集或闭集的状态
    
	int openX[mapWidth*mapHeight];      // 储存开集中区块的X坐标
	int openY[mapWidth*mapHeight];      // 储存开集中区块的Y坐标
	int parentX[mapWidth+1][mapHeight+1]; // 每个区块的父区块X坐标
	int parentY[mapWidth+1][mapHeight+1]; // 每个节点的父区块的Y坐标
    
	int Fcost[mapWidth*mapHeight];	  // 开集中所有区块的F值
	int Gcost[mapWidth][mapHeight];   // 开集中所有区块的G值
	int Hcost[mapWidth*mapHeight];	  // 开集中所有区块的H值
	
    int pathLength;       // 储存路径长度             // FindPath()
	int pathLocation;     // 储存当前位置（在路径上）    // ReadPath()
	int* pathStorage;     // FindPath()
    int pathStatus;    // FindPath()
	int xPath;         // ReadPath()
	int yPath;         // ReadPath()
    
    int* randLoc; 
    int realAvailableNodesNumber;
}

@property int pathLength; 

- (id) init;
- (void) dealloc;
- (void) initializePathFind;
- (void) terminatePathFind;

- (int) FindPath:(int)startingX yStart:(int)startingY xTarget:(int)targetX yTarget:(int)targetY;
- (void) ReadPath:(int)currentX currentY:(int)currentY speed:(int)pixelsPerFrame;
- (void) setWalkabilityCoordX:(int)x CoordY:(int)y walkBility: (MapNodeWalkability) walkBility; 
- (int*) getPathStorage;

- (int*) generateRandomObjectsNumber:(int)number Width:(int)width Height:(int)height;
- (BOOL) justifyDistrictWidth:(int)width Height:(int)height startPositionX:(int)x startPostionY:(int)y;

@end
